package com.ruoyi.common.DataConversion;


import com.ruoyi.common.domin.MainObject;
import com.ruoyi.common.domin.TypeConvertUtils;
import struct.StructClass;
import struct.StructField;

import java.util.Date;

/**
 * @ClassName UpWriteParametersNewPackage
 * @Description: 写参数应答包（上行包）
 * @Auther: 张勇
 * @Date: 2024-10-06
 * @Version: 1.0.0.0
 */
@StructClass
public class UpWriteParametersNewPackage {
    /**
     * 唯一码
     */
    @StructField(order = 0)
    public byte[] uniqueCode = new byte[2];
    /**
     * 操作结果
     */
    @StructField(order = 1)
    public byte[] result = new byte[1];
    /**
     * 地址
     */
    @StructField(order = 2)
    public byte[] address = new byte[2];


    /**
     * 接收时间
     */
    private Date receiveTime;

    /**
     * 获取上行唯一码
     *
     * @return
     */
    public String getUniqueCode() {
        return TypeConvertUtils.byteArrayToString(uniqueCode);
    }

    /**
     * 获取地址编号
     *
     * @return
     */
    public String getAddress() {
        return TypeConvertUtils.byteArrayReverseToString(address);
    }

    /**
     * 获取操作结果
     * @return
     */
    public String getResult() {
        //操作结果
        int operateResult=TypeConvertUtils.bytesToReverseInt(result);
//        if (MainObject.ERROR_CODE_DESCRIPTION.containsKey(operateResult)){
//            return MainObject.ERROR_CODE_DESCRIPTION.get(operateResult);
//        }else{
//            return "操作未知";
//        }
        return null;
    }

    /**
     * 获取接收时间
     * @return
     */
    public Date getReceiveTime() {
        return receiveTime;
    }

    /**
     * 设置接收时间
     * @param receiveTime
     */
    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }
}
